package android.medicalcloud.com.yiapp.yilian.logic;

import android.medicalcloud.com.yiapp.base.cach.PreferceManager;
import android.medicalcloud.com.yiapp.base.net.lisener.ViewNetCallBack;
import android.medicalcloud.com.yiapp.base.utils.Logger;
import android.medicalcloud.com.yiapp.base.utils.MapBuilder;
import android.medicalcloud.com.yiapp.base.utils.StringTools;
import android.medicalcloud.com.yiapp.yilian.configer.enums.HttpConfig;
import android.medicalcloud.com.yiapp.yilian.model.BaseModeal;
import android.medicalcloud.com.yiapp.yilian.utils.net.ConnectTool;

/**
 * Created by wanggenlin on 17-5-18.
 */
public class ScheduleController {
    static ScheduleController instance;


    public static ScheduleController getInstance() {
        if (instance == null) {
            instance = new ScheduleController();
        }
        return instance;
    }
    /**
     * login
     */
    public void list(ViewNetCallBack viewNetCallBack, String date) {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.scheduleList,
                    new MapBuilder<String, Object>()
                            .add("date",date)
                            .getMap()
                    , viewNetCallBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }


    /**
     * login
     */
    public void refer(ViewNetCallBack viewNetCallBack, String date) {
        try {
            ConnectTool.httpRequest(
                    HttpConfig.scheduleRefer,
                    new MapBuilder<String, Object>()
                            .add("date",date)
                            .getMap()
                    , viewNetCallBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

    /**
     * login
     */
    public void save(ViewNetCallBack viewNetCallBack, String date,int forenoon,int afternoon) {
        try {
            Logger.e("-forenoon-nidaye--"+forenoon);
            Logger.e("-afternoon-nidaye--"+afternoon);
            ConnectTool.httpRequest(
                    HttpConfig.scheduleSave,
                    new MapBuilder<String, Object>()
                            .add("date",date)
                            .add("forenoon",String.valueOf(forenoon))
                            .add("afternoon",String.valueOf(afternoon))
                            .getMap()
                    , viewNetCallBack
                    , BaseModeal.class);
        } catch (Exception e) {
            Logger.e(e.getLocalizedMessage(), e);
        }
    }

}
